package com.sise.bl.entity;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;


/**
 * 对应数据库的商品表
 */
@Component
public class Product implements Serializable {

    private static final long serialVersionUID = 1L;

    private Integer pid;
    private String pname;
    private Date ptime; //商品的上架时间！ 数据库date --> java.util.Date
    private String pimage; //商品的图片名称
    private int pstate; //商品的热门指数
    private String pinfo; //商品的描述
    private BigDecimal pprice; //价格
    private Type type;
    private Set<Item> items = new HashSet<Item>();
    private Set<Cart> carts = new HashSet<Cart>();

    public Product() {
    }

    public Product( String pname, Date ptime, String pimage, int pstate, String pinfo, BigDecimal pprice) {
        this.pname = pname;
        this.ptime = ptime;
        this.pimage = pimage;
        this.pstate = pstate;
        this.pinfo = pinfo;
        this.pprice = pprice;
    }

    public Integer getPid() {
        return pid;
    }

    public void setPid(Integer pid) {
        this.pid = pid;
    }

    public String getPname() {
        return pname;
    }

    public void setPname(String pname) {
        this.pname = pname;
    }

    public Date getPtime() {
        return ptime;
    }

    public void setPtime(Date ptime) {
        this.ptime = ptime;
    }

    public String getPimage() {
        return pimage;
    }

    public void setPimage(String pimage) {
        this.pimage = pimage;
    }

    public int getPstate() {
        return pstate;
    }

    public void setPstate(int pstate) {
        this.pstate = pstate;
    }

    public String getPinfo() {
        return pinfo;
    }

    public void setPinfo(String pinfo) {
        this.pinfo = pinfo;
    }

    public BigDecimal getPprice() {
        return pprice;
    }

    public void setPprice(BigDecimal pprice) {
        this.pprice = pprice;
    }

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    public Set<Item> getItems() {
        return items;
    }

    public void setItems(Set<Item> items) {
        this.items = items;
    }

    public Set<Cart> getCarts() {
        return carts;
    }

    public void setCarts(Set<Cart> carts) {
        this.carts = carts;
    }

    @Override
    public String toString() {
        return "Product{" +
                "pid=" + pid +
                ", pname='" + pname + '\'' +
                ", ptime=" + ptime +
                ", pimage='" + pimage + '\'' +
                ", pstate=" + pstate +
                ", pinfo='" + pinfo + '\'' +
                ", pprice=" + pprice +
                ", type=" + type +
                ", items=" + items +
                ", carts=" + carts +
                '}';
    }
}
